package com.baor.controller;

import com.baor.domain.StuVo;
import com.baor.service.StudentService;
import com.baor.service.impl.StudentServiceImpl;
import com.baor.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping(value = "/student")
public class StudentController {
    @Autowired
    private StudentService studentService;
    @RequestMapping(value = "stuList")
    public AjaxResult<?> userList(@RequestBody Map<String, Object> map){
        return this.studentService.stuList(map);
    }
    @RequestMapping(value = "searchStu")
    public AjaxResult<?> searchStu(@RequestBody Map<String,Object> param){
        int pageindex = (int) param.get("pageindex");
        int pagenum = (int) param.get("pagenum");
        param.put("pageindex",(pageindex-1)*pagenum);
        return this.studentService.searchStu(param);
    };
    @RequestMapping(value = "deleteStu")
    public AjaxResult<?> deleteStu(@RequestBody Map<String,Object> stuId){
        return this.studentService.deleteStu(stuId);
    }
    @RequestMapping(value = "stuInfo")
    public AjaxResult<?> stuInfo(@RequestBody Map<String,Object> param){
        return this.studentService.stuInfo(param);
    }
    @RequestMapping(value = "updateStu")
    public AjaxResult<?> updateStu(@RequestBody Map<String,Object> param){
        return this.studentService.updateStu(param);
    }
    @RequestMapping(value = "addStu")
    public AjaxResult<?> addStu(@RequestBody StuVo stuVo){
        return this.studentService.addStu(stuVo);
    }

    @RequestMapping(value = "selectClazz")
    public AjaxResult<?> selectClazz(){
        return this.studentService.selectClazz();
    }
}
